use "${clean}analysis.dta", clear
keep if north == 1
drop if congress > 55
drop if congress < 37

// dropping third parties
drop if partyid == 2 | partyid == .


//standardizing variables
egen birth_county_surban = std(birth_county_urban_percent)
egen birth_county_srugged = std(birth_county_ruggedness)
egen birth_county_spostoffice = std(birth_county_postoffice_area)
egen sborn = std(born)

// creating a variable to keep the sample constant
cap drop sample
gen sample = 1
foreach var of varlist $county_bcontrols $life_controls {
	replace sample = . if `var' == .
}


// estimates
estimates clear

qui eststo: mixed singular i.year i.partyid if sample == 1  || bioguide_id:
estadd local fe "Yes"

qui eststo: mixed singular i.year i.partyid ${county_bcontrols} ${life_controls} if sample == 1 || bioguide_id:
estadd local fe "Yes"	


esttab est* using "${output}TabS1_congress_north_postwar.tex", replace ///
	b(%8.3f) se(%8.3f) transform(ln*: exp(@) exp(@)) ///
	starlevels(+ 0.10 * 0.05 ** 0.01 *** 0.001) ///
	scalars("fe Congress Fixed Effects") ///
	keep( ///		
		1.partyid ///
		birth_county_surban birth_county_spostoffice birth_county_srugged birth_county_anyriver birth_county_anycanal ///
		sborn college usmilitary ///
		_cons) ///
	order( ///
	1.partyid ///
		birth_county_surban birth_county_spostoffice birth_county_srugged birth_county_anyriver birth_county_anycanal ///
		sborn college usmilitary ///
		_cons) ///
	coeflabels( ///
		year "Year of Speech" ///
		0.partyid "Democrat" ///
		1.partyid "Republican" ///
		birth_county_surban "County of Birth: \% Urban (std)" /// 
		birth_county_spostoffice "County of Birth: Post Office Density (std)" ///
		birth_county_srugged "County of Birth: Terrain Ruggedness (std)" ///
		birth_county_anyriver "Born on River" ///
		birth_county_anycanal "Born on Canal" ///
		sborn "Year of Birth (std)" ///
		college "Attended College" ///
		usmilitary "Served in US Military" ///
		_cons "Constant" ///
		) ///
	nodepvars nomtitles nonotes ///
	eqlabels("" "sd(Congress)" "sd(Bioguide)" "sd(Residual)", none) ///
	nogaps nolines posthead(\midrule) prefoot(\midrule) postfoot("\bottomrule \end{tabular}}") ///
	tex compress	

